<?php

namespace app\model;

use think\Model;

class PublicSaleRule extends Model
{

    /**
     * 公示栏规则库
     */
    protected $createTime='create_date';

    public function addRule($data)
    {
        return self::create($data);
    }

    //查询所有规则
    public function getBetweenRule():array
    {
        return $this->where (['is_k'=>1,])->select ()->toArray ();
    }


    public function getRuleModel():array
    {
        return $this->select ()->toArray ();
    }

    public function delRuleModel($id)
    {
        return self::destroy($id);
    }

    public function editRuleModel($data){
        return self::update ($data);
    }

    /**
     * 获取某个规则人员
     * @param int $id
     * @return \app\model\PublicSaleRule|array|mixed|\think\Model|null
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function getSaleRuleUid(int $id=4)
    {
        return $this->where(['id'=>$id])->find();
    }

}